<template>
  <div>
    <!-- <el-breadcrumb separator-icon="ArrowRight" style="margin: 16px">
      <el-breadcrumb-item :to="{ path: '/AdminHome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/houseAudition' }">房源信息管理</el-breadcrumb-item>
      <el-breadcrumb-item>房源信息展示</el-breadcrumb-item>
      <router-link to="/houseAudition" style="position: relative; right: -72%;">
        <el-button type="primary" style="width: 55px; height: 33px; font-size: 14px; font-family: 'Segoe UI'; border-radius: 10px;">返回</el-button>
      </router-link>
    </el-breadcrumb> -->
    <el-card style="margin: 15px; min-height: calc(100vh - 111px)">
      <div class="common-layout">
        <el-container>
        <el-header>
            <h1 style="font-size: 26px; font-weight: bold; text-align: center; ">{{ Data.title }}</h1>
            <el-tag
            :type="getStatusTagType(Data.status)" 
            size="large" style="position: relative; left: 94%; top: -57%; font-weight: bold; font-size: 14px;">
              {{ getStatusLabel(Data.status) }}
            </el-tag>
        </el-header>
        <el-container>
          <el-aside width="500px">
            <el-image :src="Data.imageUrl" fit="fill" style="width: 100%; height: 100%; border-radius: 10px;"></el-image>
          </el-aside>
          <el-main>
            <el-col :gutter="20" style="margin-top: -20px;">
              <el-row :span="8"><p><strong>住房名称：</strong>{{ Data.title }}</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>住房编号：</strong>{{ Data.houseId }}</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>房东编号：</strong>{{ Data.landlordId }}</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>所在地区：</strong>{{ Data.area }}</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>地址：</strong>{{ Data.address }}</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>住房描述：</strong>{{ Data.description }}</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>住房面积：</strong>{{ Data.size }} 平方米</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>户型：</strong>{{ Data.roomCount }} 居室</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>楼层：</strong>{{ Data.floor }} 层</p></el-row>
              <el-row :span="8" style="margin-top: 5px;"><p><strong>租金：</strong>{{ Data.price }} 元/月</p></el-row>
            </el-col>
          </el-main>
        </el-container>
            <!-- 评论区 -->
            <el-main style="margin-top: 20px;">
              <div style="display: flex; align-items: center; margin-bottom: 15px;">
                <h2 style="font-size: 20px; font-weight: bold;">用户评论 ({{ commentCount }})</h2>
                <div class="line" style="margin-left: 1.5%; flex: 1; height: 1px; background-color: #eee;"></div>
              </div>  

              <!-- 评论列表（评论数>0时显示） -->
              <div v-if="comments.length > 0">
                <div 
                  v-for="comment in comments" 
                  :key="comment.id" 
                  style="margin-bottom: 15px; padding: 15px; border: 1px solid #ebeef5; border-radius: 4px;"
                >
                  <!-- 评论头部：用户信息+评分+时间 -->
                  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
                    <div>
                      <span style="font-weight: 600; color: #303133;">{{ userMap[comment.tenantId] || '匿名用户' }}</span>
                      <el-rate 
                        v-model="comment.rating" 
                        disabled 
                        :colors="['#99A9BF', '#F7BA1E', '#FF9900']" 
                        style="margin-left: 10px;"
                      />
                    </div>
                    <span style="font-size: 12px; color: #909399;">{{ formatDate(comment.commentTime) }}</span>
                  </div>
                  <!-- 评论内容 -->
                  <div style="color: #606266; line-height: 1.6;">{{ comment.content }}</div>
                </div>
              </div>

              <!-- 暂无评论（评论数=0时显示） -->
              <div v-else style="text-align: center; padding: 50px 0; color: #909399;">
                暂无评论
              </div>
            </el-main>
        </el-container>
      </div>
    </el-card>
  </div>
</template>

<script src="@/assets/js/AdminAuditionHouseDisplay.js"></script>

